home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / glibc108.gz / glibc108 / glibc-1.08.1 / time / sys / time.h next >
C/C++ Source or Header  |  1994-02-22  |  5KB  |  129 lines

  1. /* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. #ifndef _SYS_TIME_H
  20.  
  21. #define _SYS_TIME_H    1
  22. #include <features.h>
  23.  
  24. #include <time.h>
  25.  
  26. __BEGIN_DECLS
  27.  
  28. /* A time value that is accurate to the nearest
  29.    microsecond but also has a range of years.  */
  30. struct timeval
  31.   {
  32.     int tv_sec;        /* Seconds.  */
  33.     int tv_usec;    /* Microseconds.  */
  34.   };
  35.  
  36. /* Structure crudely representing a timezone.
  37.    This is obsolete and should never be used.  */
  38. struct timezone
  39.   {
  40.     int tz_minuteswest;    /* Minutes west of GMT.  */
  41.     int tz_dsttime;    /* Nonzero if DST is ever in effect.  */
  42.   };
  43.  
  44. /* Get the current time of day and timezone information,
  45.    putting it into *TV and *TZ.  If TZ is NULL, *TZ is not filled.
  46.    Returns 0 on success, -1 on errors.
  47.    NOTE: This form of timezone information is obsolete.
  48.    Use the functions and variables declared in <time.h> instead.  */
  49. extern int __gettimeofday __P ((struct timeval *__tv,
  50.                 struct timezone *__tz));
  51. extern int gettimeofday __P ((struct timeval *__tv,
  52.                   struct timezone *__tz));
  53.  
  54. /* Set the current time of day and timezone information.
  55.    This call is restricted to the super-user.  */
  56. extern int __settimeofday __P ((__const struct timeval *__tv,
  57.                 __const struct timezone *__tz));
  58. extern int settimeofday __P ((__const struct timeval *__tv,
  59.                   __const struct timezone *__tz));
  60.  
  61. /* Adjust the current time of day by the amount in DELTA.
  62.    If OLDDELTA is not NULL, it is filled in with the amount
  63.    of time adjustment remaining to be done from the last `adjtime' call.
  64.    This call is restricted to the super-user.  */
  65. extern int __adjtime __P ((__const struct timeval *__delta,
  66.                struct timeval *__olddelta));
  67. extern int adjtime __P ((__const struct timeval *__delta,
  68.              struct timeval *__olddelta));
  69.  
  70.  
  71. /* Values for the first argument to `getitimer' and `setitimer'.  */
  72. enum __itimer_which
  73.   {
  74.     /* Timers run in real time.  */
  75.     ITIMER_REAL = 0,
  76.     /* Timers run only when the process is executing.  */
  77.     ITIMER_VIRTUAL = 1,
  78.     /* Timers run when the process is executing and when
  79.        the system is executing on behalf of the process.  */
  80.     ITIMER_PROF = 2
  81.   };
  82.  
  83. /* Type of the second argument to `getitimer' and
  84.    the second and third arguments `setitimer'.  */
  85. struct itimerval
  86.   {
  87.     /* Value to put into `it_value' when the timer expires.  */
  88.     struct timeval it_interval;
  89.     /* Time to the next timer expiration.  */
  90.     struct timeval it_value;
  91.   };
  92.  
  93. /* Set *VALUE to the current setting of timer WHICH.
  94.    Return 0 on success, -1 on errors.  */
  95. extern int __getitimer __P ((enum __itimer_which __which,
  96.                  struct itimerval *__value));
  97. extern int getitimer __P ((enum __itimer_which __which,
  98.                struct itimerval *__value));
  99.  
  100. /* Set the timer WHICH to *NEW.  If OLD is not NULL,
  101.    set *OLD to the old value of timer WHICH.
  102.    Returns 0 on success, -1 on errors.  */
  103. extern int __setitimer __P ((enum __itimer_which __which,
  104.                  struct itimerval *__new,
  105.                  struct itimerval *__old));
  106. extern int setitimer __P ((enum __itimer_which __which,
  107.                struct itimerval *__new,
  108.                struct itimerval *__old));
  109.  
  110. /* Change the access time of FILE to TVP[0] and
  111.    the modification time of FILE to TVP[1].  */
  112. extern int __utimes __P ((__const char *__file, struct timeval __tvp[2]));
  113. extern int utimes __P ((__const char *__file, struct timeval __tvp[2]));
  114.  
  115.  
  116. /* Convenience macros for operations on timevals.
  117.    NOTE: `timercmp' does not work for >= or <=.  */
  118. #define    timerisset(tvp)        ((tvp)->tv_sec || (tvp)->tv_usec)
  119. #define    timercmp(tvp, uvp, CMP)    \
  120.   ((tvp)->tv_sec CMP (uvp)->tv_sec || \
  121.    (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec CMP (uvp)->tv_usec)
  122. #define    timerclear(tvp)        ((tvp)->tv_sec = (tvp)->tv_usec = 0)
  123.  
  124.  
  125.  
  126. __END_DECLS
  127.  
  128. #endif /* sys/time.h */
  129.